import type { BuyAgainResData } from '@/types/order'
import type { CartTypeData } from '@/types/cart'
import { http } from '@/utils/http'

export default {
  getCartNumber: () => {
    //获取订单列表数据
    return http<number>({
      method: 'GET',
      url: '/v1/shop/cart/sumNumber',
    })
  },
  // 删除订单
  delOrderById: (id_: number) => {
    return http<null>({
      method: 'GET',
      url: `/v1/shop/order/markNotViewForShop/${id_}`,
      data: {},
    })
  },
  // 再来一单添加商品合并到购物车
  buyAgain: (jsonStr: string) => {
    return http<BuyAgainResData>({
      method: 'POST',
      url: `/v1/shop/cart/mergeCartForWeb`,
      data: {
        jsonStr: jsonStr,
      },
    })
  },
  getCartListApi: () => {
    return http<CartTypeData>({
      method: 'GET',
      url: `/v1/shop/pisen/cart/getCartList`,
    })
  },
  updateCarApi: (data: { cartId: number; qty: number }) => {
    return http<any>({
      method: 'POST',
      url: `/v1/shop/pisen/cart/updateCart`,
      header: {
        'Content-Type': 'application/json;charset=utf-8',
      },
      data: data,
    })
  },
}
